<?php


class b2c_ctl_wap_common extends wap_frontpage{  
    
    function __construct(&$app){
        parent::__construct($app);
        $this->header .= '<meta name="robots" content="noindex,noarchive,nofollow" />';
        $this->_response->set_header('Cache-Control', 'no-store');
        $this->pagesize = 10;
        $this->action_view = $this->action.".html";
        $this->pagedata['app'] =1;
        foreach($_REQUEST as $k=>$v){
            if(strtoupper($k) == "FROM"){
                $this->pagedata['app'] = $_REQUEST[$k] == "app" ? 1 : 0;
            }
        }
//        微信分享链接
//        $res = kernel::single('b2c_share_JSSDK')->getSignPackage();
//        $this->pagedata['appId'] = $res['appId'];
//        $this->pagedata['timestamp'] = $res['timestamp'];
//        $this->pagedata['nonceStr'] = $res['nonceStr'];
//
//        $this->pagedata['signature'] = $res['signature'];
        //end结束
    }
    public function getApi($filter = array()){
        foreach($filter as $k=>$val){
            $_POST[$k] = $val;
        }
        $return = kernel::single($filter['method']['file'])->$filter['method']['action']($filter['data']);
        if($return ){
            return array(
                "data"=>$return,
                "status" => true
            );
        }else{
            return array(
                "data"=>array(),
                "status" => false
            );
        }
    }
    /**
     * 把对象转换为数组方法一（推荐）
     * @return 数组，可以把一个对象数组混合对象转换为纯数组
     */
    function obj2arr(&$object) {
		$object =  json_decode( json_encode( $object),true);
		return  $object;
    }
		
    /**
     * 把对象转换为数组方法二
     * @return 数组，可以把一个对象数组混合对象转换为纯数组
     */
	function obj2arr2($array) {
		if(is_object($array)) {  
			$array = (array)$array;  
		}
		if(is_array($array)) {  
			foreach($array as $key=>$value) {  
				$array[$key] = $this->obj2arr2($value);  
			}  
		}  
		return $array;	
	}


}
